<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">
    <style type="text/css">
        .tableStyle{
            margin:10px 0px 5px 0px;
        }
        .gridStyle{
            margin:10px 10px 10px 0px;
        }
        input{
            margin:1px 1px 1px 2px;
        }
        input[type='submit']{
            margin:3px 5px 3px 5px;
            padding:2px 5px 2px 5px;
        }
        .top{
            vertical-align: top;
        }
    </style>
    <h:form>
        <rich:panel header="采购类目" id="catePanel" styleClass="content-hight">
            <rich:messages globalOnly="true"/>
            <rich:toolbar  itemSeparator="grid" id="tolbar">
                <rich:toolbarGroup>
                    <a4j:commandButton value="新建" execute="@this" render="edit,tolbar"
                                       action="#{categoryBean.add}"/>
                    <a4j:commandButton value="修改" execute="@this" render="edit,tolbar"
                                       action="#{categoryBean.update}"
                                       disabled="#{categoryBean.addOrUpdate or empty categoryBean.node}"/>
                    <a4j:commandButton value="删除" render="catePanel" action="#{categoryBean.delete}"
                                       disabled="#{categoryBean.addOrUpdate or empty categoryBean.node}"/>
                    <a4j:commandButton value="保存" render="catePanel"  action="#{categoryBean.checkSave}"
                                       disabled="#{!categoryBean.editStatus}"/>
                    <a4j:commandButton value="取消" execute="@this" render="edit,tolbar"
                                       action="#{categoryBean.cancel}"/>
                </rich:toolbarGroup>
            </rich:toolbar>
            <h:panelGrid columns="2" width="100%" columnClasses="top,top">
                <rich:tree value="#{categoryBean.rootNode}" var="idept"
                           selectionType="ajax" toggleType="client"
                           selectionChangeListener="#{categoryBean.selected}"
                           style="width:300px" render="catePanel">
                    <rich:treeNode>
                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                    </rich:treeNode>
                </rich:tree>
                <h:panelGroup style="margin:10px" id="edit">
                    <h:panelGrid columns="3" styleClass="gridStyle">
                        <h:outputText value="代码："/>
                        <h:outputText rendered="#{!categoryBean.editStatus}" value="#{categoryBean.node.code}"/>
                        <h:inputText rendered="#{categoryBean.editStatus}" disabled="#{!categoryBean.addOrUpdate}" id="code" value="#{categoryBean.node.code}"/>
                        <rich:message for="code"/>
                        <h:outputText value="名称："/>
                        <h:outputText rendered="#{!categoryBean.editStatus}" value="#{categoryBean.node.name}"/>
                        <h:inputText rendered="#{categoryBean.editStatus}" id="name" value="#{categoryBean.node.name}"/>
                        <rich:message for="name"/>
                        <h:outputText value="计量单位：" rendered="#{categoryBean.node.isEnd eq 1 or categoryBean.addOrUpdate}"/>
                        <h:outputText rendered="#{!categoryBean.editStatus and categoryBean.node.isEnd eq 1}"
                                      value="#{categoryBean.node.unit}"/>
                        <h:inputText rendered="#{(categoryBean.editStatus and categoryBean.node.isEnd eq 1)
                                                 or categoryBean.addOrUpdate}"
                                     id="unit" value="#{categoryBean.node.unit}"/>
                        <rich:message for="unit"/>
                    </h:panelGrid>
                </h:panelGroup>
            </h:panelGrid>
        </rich:panel>
    </h:form>
</html>
